package ru.yermak.bookkeeping.ui;

import org.springframework.beans.factory.annotation.Autowired;

import javax.swing.*;

/**
 * User: harrier
 * Date: Sep 9, 2008
 */
@org.springframework.stereotype.Component
public class SwingModalForm implements ModalForm {
    private static final String[] options = new String[]{"OK", "Cancel"};

    @Autowired
    private JFrame mainWindow;

    public boolean show(JComponent form) {
        int result = JOptionPane.showOptionDialog(mainWindow, form, form.getName(),
                JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
        return result == 0;
    }
}
